//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins

mixin discovery-cloud(modelAt='$ctrl.clonedCluster')

    -const model = `${modelAt}.discovery.Cloud`
    -const discoveryKind = 'Cloud'
    -const required = `${modelAt}.discovery.kind == "${discoveryKind}"`
    -const regions = `${model}.regions`
    -const zones = `${model}.zones`
    -const formRegions = 'discoveryCloudRegions'
    -const formZones = 'discoveryCloudZones'

    div.pc-form-grid-row&attributes(attributes=attributes)
        .pc-form-grid-col-30
            +form-field__text({
                label: 'Credential:',
                model: `${model}.credential`,
                name: '"credential"',
                placeholder: 'Input cloud credential',
                tip: 'Credential that is used during authentication on the cloud<br/>\
                      Depending on a cloud platform it can be a password or access key'
            })
        .pc-form-grid-col-30
            +form-field__text({
                label: 'Path to credential:',
                model: `${model}.credentialPath`,
                name: '"credentialPath"',
                placeholder: 'Input path to credential',
                tip: 'Path to a credential that is used during authentication on the cloud<br/>\
                     Access key or private key should be stored in a plain or PEM file without a passphrase'
            })
        .pc-form-grid-col-30
            +form-field__text({
                label: 'Identity:',
                model: `${model}.identity`,
                name: '"' + discoveryKind + 'Identity"',
                required: required,
                placeholder: 'Input identity',
                tip: 'Identity that is used as a user name during a connection to the cloud<br/>\
                     Depending on a cloud platform it can be an email address, user name, etc'
            })
        .pc-form-grid-col-30
            +form-field__text({
                label:'Provider:',
                model: `${model}.provider`,
                name: '"' + discoveryKind + 'Provider"',
                required: required,
                placeholder: 'Input provider',
                tip: 'Cloud provider to use'
            })
        .pc-form-grid-col-60
            .ignite-form-field
                +list-text-field({
                    items: regions,
                    lbl: 'Region name',
                    name: 'regionName',
                    itemName: 'region',
                    itemsName: 'regions'
                })(
                    list-editable-cols=`::[{
                        name: 'Regions:',
                        tip: "List of regions where VMs are located<br />
                        If the regions are not set then every region, that a cloud provider has, will be investigated. This could lead to significant performance degradation<br />
                        Note, that some cloud providers, like Google Compute Engine, doesn't have a notion of a region. For such providers regions are redundant"
                    }]`
                )
                    +form-field__error({ error: 'igniteUnique', message: 'Such region already exists!' })
        .pc-form-grid-col-60
            .ignite-form-field
                +list-text-field({
                    items: zones,
                    lbl: 'Zone name',
                    name: 'zoneName',
                    itemName: 'zone',
                    itemsName: 'zones'
                })(
                    list-editable-cols=`::[{
                        name: 'Zones:',
                        tip: "List of zones where VMs are located<br />
                        If the zones are not set then every zone from specified regions, will be taken into account<br />
                        Note, that some cloud providers, like Rackspace, doesn't have a notion of a zone. For such providers zones are redundant"
                    }]`
                )
                    +form-field__error({ error: 'igniteUnique', message: 'Such zone already exists!' })
